package com.cloudsigns.factorymanager2.engineering.presenter;

import com.cloudsigns.factorymanager2.engineering.IView.IPublicationOrderDetailView;
import com.cloudsigns.factorymanager2.engineering.bean.PublicationOrderDetailBean;
import com.cloudsigns.factorymanager2.engineering.model.IPublicationOrderDetailModel;
import com.cloudsigns.factorymanager2.engineering.model.PublicationOrderDetailModel;

/**[ [通用]获取工程部上下刊订单详情 ]
 * Created by tony on 2018/5/7.
 */

public class PublicationOrderDetailPresenter {
    private IPublicationOrderDetailView view;
    private IPublicationOrderDetailModel model;
    private android.os.Handler mHandler = new android.os.Handler();

    public PublicationOrderDetailPresenter(IPublicationOrderDetailView view) {
        this.view = view;
        this.model = new PublicationOrderDetailModel();
    }

    public void getPublicationOrderDetail() {


        model.getPublicationOrderDetail(view.getOrderId(), new PublicationOrderDetailModel.OnPublicationOrderDetailModelListener() {
            @Override
            public void getPublicationOrderDetailSuccessed(final PublicationOrderDetailBean publicationOrderBean) {
                //需要在UI线程执行
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.getPublicationOrderDetailSuccessed(publicationOrderBean);
                        view.hideLoading();
                    }
                });
            }

            @Override
            public void getPublicationOrderDetailFailed(final String desc) {
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.gePublicationOrderDetailFailed(desc);
                        view.hideLoading();
                    }
                });
            }


        });
    }
}
